/*
 *  libKara - Library for basic instant messaging functions
 *  Copyright (C) 2007-2008 Markus Karnik
 *
 *  This program is free software; you can redistribute it and/or modify it 
 *  under the terms of the GNU General Public License as published by the
 *  Free Software Foundation; either version 3 of the License, 
 *  or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 *  for more details.
 *
 *  You should have received a copy of the GNU General Public License along 
 *  with this program; if not, see <http://www.gnu.org/licenses/>.
 *  
 */

package de.karnik.libkara.roster;

/**
 * This class implements a simple message storage.
 * 
 * @author Markus Karnik - markus.karnik@my-design.org
 * @version 1.0
 * @since 1.0
 */
public class ImMessage {
	
	/**
	 * The incoming message type.
	 */
	public static final int INCOMING = 0;
	/**
	 * The outgoing message type.
	 */
	public static final int OUTGOING = 1;
	/**
	 * The system message type.
	 */
	public static final int SYSTEM = 2;
	
	/**
	 * The message subject value.
	 */
	private String subject = null; 
	/**
	 * The message value.
	 */
	private StringBuffer message = null;
	/**
	 * The message time stamp.
	 */
	private long timeStamp = 0;
	/**
	 * The message type indicator.
	 */
	private int type = INCOMING;
	
	/**
	 * Constructs a message object with the given text.
	 * 
	 * @param message The text for the new message object.
	 */
	public ImMessage( StringBuffer message ) {
		this( null, message );
	}
	
	/**
	 * Constructs a message object with the given text and subject.
	 * 
	 * @param subject The subject for the new message object.
	 * @param message The text for the new message object.
	 */
	public ImMessage( String subject, StringBuffer message ) {
		this.subject = subject;
		this.message = new StringBuffer( message );
	}
	
	/**
	 * Returns the subject.
	 * 
	 * @return The message subject.
	 */
	public String getSubject() {
		return subject;
	}

	/**
	 * Returns the message.
	 * 
	 * @return The text Message.
	 */
	public StringBuffer getMessage() {
		return message;
	}

	/**
	 * Return the time stamp.
	 * 
	 * @return The time stamp.
	 */
	public long getTimeStamp() {
		return timeStamp;
	}

	/**
	 * Sets the time stamp.
	 * 
	 * @param timeStamp The time stamp to set.
	 */
	public void setTimeStamp( long timeStamp ) {
		this.timeStamp = timeStamp;
	}

	/**
	 * Returns the message type.
	 * 
	 * @return The message type.
	 * 
	 * @see #INCOMING
	 * @see #OUTGOING
	 * @see #SYSTEM
	 */
	public int getType() {
		return type;
	}

	/**
	 * Sets the message type.
	 * 
	 * @param type The message type to set.
	 * 
	 * @see #INCOMING
	 * @see #OUTGOING
	 * @see #SYSTEM
	 */
	public void setType(int type) {
		this.type = type;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#clone()
	 */
	public ImMessage clone() {
		ImMessage clone = new ImMessage( subject, message );
		clone.setTimeStamp( timeStamp );
		clone.setType( type );
		
		return clone;
	}
}
